package logic

import (
	"cart_srv/model/redis"
	"context"

	"cart_srv/internal/svc"
	"cart_srv/pb/cart"

	"github.com/zeromicro/go-zero/core/logx"
)

type CartListOneLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCartListOneLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CartListOneLogic {
	return &CartListOneLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CartListOneLogic) CartListOne(in *cart.CartListOneRequest) (*cart.CartListOneResponse, error) {
	// todo: add your logic here and delete this line
	one, err := redis.ListCartOne(in.UserId, in.GoodsId)
	if err != nil {
		logx.Error("商品信息展示失败")
		return nil, err
	}

	return &cart.CartListOneResponse{List: one}, nil
}
